<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" href="__STATIC__/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/admin.css"/>
        <style>
            .category-add .layui-form-select dl{
                max-height: 150px;
            }
        </style>
	</head>
	<body>
	<form class="layui-form category-add" style="width: 90%;padding-top: 20px;">
	  <div class="layui-form-item">
	    <label class="layui-form-label">分类名称</label>
	    <div class="layui-input-block">
	      <input type="text" name="name" required  lay-verify="required" placeholder="请输入标题" value="{$category.name}" autocomplete="off" class="layui-input">
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">分类栏目</label>
	    <div class="layui-input-block">
	      <select name="parent_id" lay-verify="required">
	        <option value="0">一级栏目</option>
            {volist name='categorys' id='vo'}
	            <option value="{$vo.id}" {eq name="$category.parent_id" value="$vo.id"} selected="selected"  {else/} {/eq}>{$vo.name}</option>
	        {/volist}
	      </select>
	    </div>
	  </div>



     <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="listorder" required  lay-verify="required" value="{$category.listorder}"  autocomplete="off" class="layui-input">
            </div>
      </div>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
			<input type="hidden" name="id" required  value="{$category.id}"  autocomplete="off" class="layui-input">
	      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="categoryAdd">立即提交</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    </div>
	  </div>
	</form>
    <script>
        var SCOPE={
            static:'__STATIC__',
            updateEdit:'{:url("Category/updateEdit")}'
        }
    </script>
	<script src="__STATIC__/admin/layui/layui.js"></script>

	<script>
		layui.use(['form','jquery','layer'], function(){
		  var form = layui.form(),
              $=layui.jquery,
              layer=layui.layer;
		  form.render();
		  //监听提交$
		  form.on('submit(categoryAdd)', function(data){
		    var fieldData=data.field;
		    $.ajax({
                method :"post",
                data:fieldData,
                dataType:'json',
                url:SCOPE.updateEdit,
                success:function (res) {
                    console.log(res);
                    if(res.status==1){
                        layer.msg(res.message);
                        setTimeout(function () {
                            parent.refresh();
                        },1000)
                    }else{
                        layer.msg(res.message);
                   }
                }
            })
		    return false;
		  });




		});


	</script>
	</body>
</html>